package leetcode;

import java.util.Scanner;

public class LeetCodeMain65 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            String str=in.nextLine();
            int count=0;
            for (int i = 0; i < str.length(); i++) {
                count+=str.charAt(i)-'0';
            }
            while (count >= 10) {
                count=count%10+count/10;
            }
            System.out.println(count);
        }
    }
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        int[] arr=new int[10001];
        arr[0]=1;
        arr[1]=1;
        for (int i = 2; i < 10001; i++) {
            arr[i]=(arr[i-1]+arr[i-2])%10000;
        }
        while (in.hasNext()){
            int num=in.nextInt();
            for (int i = 0; i < num; i++) {
                System.out.printf("%04d",arr[in.nextInt()]);
            }
            System.out.printf("\n");
        }
    }

    public float aMethod(float a,float b){
        return (float) 0.0;
    }
    public float aMethod(float a,float b,int c){
        return (float) 0.0;
    }
    static boolean out(char c){
        System.out.print(c);
        return true;
    }

//    public static void main(String[] args) {
////        int i=0;
////        for (out('A');out('B')&&(i<2);out('C')){
////            i++;
////            out('D');
////        }
//        Thread t=new Thread(){
//            public void run(){
//                dianping();
//            }
//        };
//        t.run();
//        System.out.print("dazhong");
//    }
//    static void dianping(){
//        System.out.print("dianping");
//    }
}
